<#include "../template/template_listPage.ftl">
<@header title="卡号批量导出功能">
<style type="text/css">
    .page {
        float: right;
        padding-top: 15px;
        margin-right: 15px;
    }

    .searchButton table {
        padding: 1px;
        text-align: center;
    }

    .searchTable td {
        height: 30px;
    }
</style>
<script type="text/javascript">
    function exportor(filetype) {
        if (filetype != undefined && (filetype == 'txt' || filetype == 'csv')) {
            //文本文件导出
            var data = $('#listForm').serialize();
            var urlFileTypeData = 'fileType=' + filetype;
            var url = "${web_base}/recharge/card_info!export.htm?";
            if (data != undefined && data != '') {
                url = url + data + "&" + urlFileTypeData;
            } else {
                url = url + urlFileTypeData;
            }
            $('#download').attr('src',url);

            //window.open(url);
        } else if (filetype != undefined && filetype == 'xls') {

        }
    }

    $(document).ready(function () {
        $('#isSale').val('${isSale!}');
        $("input[type='radio'][name='cardStatus'][value='${cardStatus!}']").attr('checked', 'checked');
        $("input[type='radio'][name='usStatus'][value='${usStatus!}']").attr('checked', 'checked');
    });
    function modify(cardId, enable) {
        var url = '${web_base}/recharge/card_info!modifyCard.htm?cardId=' + cardId;
        var result = false;
        if (enable) {
            result = confirm("你确认要禁用吗?");
        }
        else {
            result = confirm("你确认要启用吗?");
        }
        if (result) {
//                $('#listForm').attr('action',url);
//                $('#listForm').submit();
            $.ajax({
                type:"POST",
                url:url,
                data:"",
                success:function (msg) {
                    if (msg != undefined && msg == 'error') {
                        alert("修改失败!");
                    } else {
                        $('#searchButton').click();
                    }
                }
            });
        }
    }
    function batchOperation() {
        ymPrompt.win('${web_base}/recharge/card_info!toBatchOperate.htm', 400, 150, '批量操作', null, null, null, {id:'b'});
    }
    function goback() {
        window.location.href = '${web_base}/recharge/card_management!list.htm';
    }
</script>
</@header>
<body class="list">
<div class="body">
    <div class="listBar">
        <h1><span class="icon">&nbsp;</span>您当前的位置&nbsp;<span class="pageInfo">[单一产品库存查看]</span></h1>
    </div>
<#-- ${web_base}/lead/leadout_data!toLeadout.htm -->
<@pageList page=(page!) id="listForm" action="${web_base}/recharge/card_info!list.htm" query="cardInfoQuery" isEmpty=true>
    <div class="operateBar" style="margin-left: 30px;">
        <table class="searchTable">
            <tr>
                <td>产品名称:</td>
                <td>${cardName!}<input type="hidden" name="cardName" value="${cardName!}">
                    <input type="hidden" name="systemProductId" value="${systemProductId!}">
                </td>
            </tr>
            <tr>
                <td>卡&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号:</td>
                <td><input type="text" name="cardSerial" value="${cardSerial!}"></td>
            </tr>
            <tr>
                <td>批&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;次:</td>
                <td><input type="text" name="cardBatchNo" value="${cardBatchNo!}"></td>
            </tr>
            <tr>
                <td>导入时间:</td>
                <td><input type="text" name="importStartDate" onclick="WdatePicker()"
                           value="${importStartDate!}" class="Wdate">-
                    <input type="text" name="importEndDate" onclick="WdatePicker()"
                           value="${importEndDate!}" class="Wdate">
                </td>
            </tr>
            <tr>
                <td>退卡时间:</td>
                <td><input type="text" name="returnCardStartDate" onclick="WdatePicker({readOnly:true})"
                           value="${returnCardStartDate!}" class="Wdate">-
                    <input type="text" name="returnCardEndDate" onclick="WdatePicker({readOnly:true})"
                           value="${returnCardEndDate!}" class="Wdate">
                    <span> 建议在导退卡时，取消导入时间</span>
                </td>
            </tr>
            <tr>
                <td>状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态:</td>
                <td><input type="radio" name="cardStatus" value="" id="allstatus" checked="checked"><label
                        for="allstatus" style="padding: 5px;">所有</label>
                    &nbsp;<input type="radio" name="cardStatus" value="1" id="allowstatus"><label
                            for="allowstatus" style="padding: 5px;">在库</label>
                    &nbsp;<input type="radio" name="cardStatus" value="2" id="outstorage"><label for="outstorage"
                                                                                                 style="padding: 5px;">出库</label>
                <#--    &nbsp;<input type="radio" name="cardStatus" value="3" id="used"><label for="used"
                                                                                           style="padding: 5px;">已使用</label>
                    &nbsp;<input type="radio" name="cardStatus" value="4" id="errorcard"><label
                            for="errorcard" style="padding: 5px;">错卡</label>-->
                    &nbsp;<input type="radio" name="cardStatus" value="5" id="refundcard"><label
                            for="refundcard" style="padding: 5px;">退卡</label>
                </td>
            </tr>
            <tr>
                <td>起禁状态:</td>
                <td><input type="radio" name="usStatus" value="" id="ssall" checked="checked"><label
                        for="ssall" style="padding: 5px;">所有</label>
                    &nbsp;<input type="radio" name="usStatus" value="1" id="ssallow"><label for="ssallow"
                                                                                            style="padding: 5px;">启用</label>
                    &nbsp;<input type="radio" name="usStatus" value="0" id="ssforbidden"><label
                            for="ssforbidden" style="padding: 5px;">禁用</label>
                </td>
            </tr>
        </table>
    <#--     <label>是否已经销售:</label>
<select id="isSale" name="isSale">
<option value="">&nbsp;</option>
<option value="1">是</option>
<option value="0">否</option>
</select>
<label>销售日期:</label>
<label>起:</label><input type="text" id="startdate" name="startdate" onClick="WdatePicker({readOnly:true})"
value="${startdate}" class="Wdate"/>
<label>止:</label><input type="text" id="enddate" name="enddate" onClick="WdatePicker({readOnly:true})"
value="${enddate}" class="Wdate">    -->
        <button type="submit" id="searchButton">查询</button>
        <button type="button" onclick="goback();">返回产品</button>

        <button type="button" onclick="batchOperation();">批量操作</button>
        <br>

        <div style="margin: 5px 0 0 0;">
            <span>导出卡密信息:</span>
            <button onclick="exportor('txt');" class="" style="color: blue;" type="button">文本格式</button>
            <button onclick="exportor('csv');" class="" style="color: blue;" type="button">CSV格式</button>
            &nbsp;<span style="color: red;">超过一万条数据无法导出!</span>
        </div>
    </div>
    <table class="listTable">
        <tr>
            <th><span class="sort">序号</span></th>
            <th><span class="sort">批号</span></th>
            <th><span class="sort">运营商</span></th>
            <th><span class="sort">可充区域</span></th>
            <th><span class="sort">卡号</span></th>
            <th><span class="sort">面额</span></th>
            <th><span class="sort">导入时间</span></th>
            <th><span class="sort">有效期</span></th>
            <th><span class="sort">进货日期</span></th>
            <th><span class="sort">进货源</span></th>
            <th><span class="sort">使用级别</span></th>
            <th><span class="sort">状态</span></th>
            <th><span class="sort">备注</span></th>
            <th><span class="sort">操作</span></th>
        </tr>
        <#if  page??&&page.list??&&(page.list?size gt 0) >
            <#list page.list as obj>
                <tr>
                    <td>${obj_index+page.pageSize*(page.currentPage-1)+1}</td>
                    <td>${obj.cardImportBatchNum!}</td>
                    <td>${obj.operatingAgenciesName!}</td>
                    <td>${obj.providerName!}${obj.adaptableAreaName!}</td>
                    <td>${obj.cardSerial!}</td>
                    <td>${obj.cardPrice!}</td>
                <#-- <td>${obj.cardPassword!}</td>-->
                    <td><#if (obj.createTime)??>${obj.createTime?string("yyyy-MM-dd")}</#if></td>
                    <td><#if (obj.cardEffectTime)??>${obj.cardEffectTime?string("yyyy-MM-dd")}</#if></td>
                    <td>&nbsp;</td>
                    <td>${obj.stockSupplierName!}</td>
                    <td>${obj.useLevel!}</td>
                    <td><span style="display: none;">${obj.status!}</span>${obj.statusName}</td>
                    <td>${obj.remark!}</td>
                    <td><span class="spanLink"
                              onclick="modify('${obj.cardId!}',${obj.enable?string('true','false')});"><#if obj.enable>
                        禁用<#else ><label style="color: red;cursor: pointer">启用</label></#if></span></td>
                </tr>
            </#list>
        </#if>

    </table>
</@pageList>
    <iframe id="download" style="display: none;"></iframe>
</div>
</body>
</html>